package com.guit.hrms.mapper;

import com.guit.hrms.po.interview.Onboarding;
import com.guit.hrms.po.onboarding.OnboardingVO;
import jakarta.validation.constraints.NotNull;
import org.apache.ibatis.annotations.*;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface OnboardingMapper {
    /**
     * 新增待入职信息
     * @param onboarding 待入职信息
     * @return 结果
     */
    @Insert("INSERT INTO onboarding(offer_id,interviewee_id,onboarding_time,onboarding_place,status,update_time,update_by) VALUES(#{offerId},#{intervieweeId},#{onboardingTime},#{onboardingPlace},#{status},#{updateTime},#{updateBy})")
    Integer insertOnboarding(Onboarding onboarding);

    /**
     * 获取待办理入职的信息
     * @param onboardingTime 入职办理时间
     * @param onboardingPlace 入职办理地点
     * @return 结果
     */
    List<OnboardingVO> getOfferResult(Integer status,LocalDateTime onboardingTime, String onboardingPlace);

    /**
     * 根据面试者id删除待入职信息
     * @param intervieweeId 面试者id
     * @return 结果
     */
    @Delete("DELETE FROM onboarding WHERE interviewee_id = #{intervieweeId}")
    Integer deleteOnboardingByIntervieweeId(Integer intervieweeId);

    /**
     * 根据id获取入职信息
     * @param id 入职信息id
     * @return 入职信息
     */
    @Select("SELECT * FROM onboarding WHERE id = #{id}")
    Onboarding getOnboardingById(Integer id);

    @Update("update onboarding set status = #{status},update_time = #{updateTime},update_by = #{updateBy} where id = #{id}")
    Integer updateOnboardingStatus(Integer id, Integer status, LocalDateTime updateTime, String updateBy);
}
